export const CURRENCIES = {
  USD: {
    symbol: '$',
    symbolNative: '$',
    decimalDigits: 2,
    rounding: 0,
    code: 'USD',
  },
  CAD: {
    symbol: 'CA$',
    symbolNative: '$',
    decimalDigits: 2,
    rounding: 0,
    code: 'CAD',
  },
  EUR: {
    symbol: '€',
    symbolNative: '€',
    decimalDigits: 2,
    rounding: 0,
    code: 'EUR',
  },
  AED: {
    symbol: 'AED',
    symbolNative: 'د.إ.‏',
    decimalDigits: 2,
    rounding: 0,
    code: 'AED',
  },
  AFN: {
    symbol: 'Af',
    symbolNative: '؋',
    decimalDigits: 0,
    rounding: 0,
    code: 'AFN',
  },
  ALL: {
    symbol: 'ALL',
    symbolNative: 'Lek',
    decimalDigits: 0,
    rounding: 0,
    code: 'ALL',
  },
  AMD: {
    symbol: 'AMD',
    symbolNative: 'դր.',
    decimalDigits: 0,
    rounding: 0,
    code: 'AMD',
  },
  ARS: {
    symbol: 'AR$',
    symbolNative: '$',
    decimalDigits: 2,
    rounding: 0,
    code: 'ARS',
  },
  AUD: {
    symbol: 'AU$',
    symbolNative: '$',
    decimalDigits: 2,
    rounding: 0,
    code: 'AUD',
  },
  AZN: {
    symbol: 'man.',
    symbolNative: 'ман.',
    decimalDigits: 2,
    rounding: 0,
    code: 'AZN',
  },
  BAM: {
    symbol: 'KM',
    symbolNative: 'KM',
    decimalDigits: 2,
    rounding: 0,
    code: 'BAM',
  },
  BDT: {
    symbol: 'Tk',
    symbolNative: '৳',
    decimalDigits: 2,
    rounding: 0,
    code: 'BDT',
  },
  BGN: {
    symbol: 'BGN',
    symbolNative: 'лв.',
    decimalDigits: 2,
    rounding: 0,
    code: 'BGN',
  },
  BHD: {
    symbol: 'BD',
    symbolNative: 'د.ب.‏',
    decimalDigits: 3,
    rounding: 0,
    code: 'BHD',
  },
  BIF: {
    symbol: 'FBu',
    symbolNative: 'FBu',
    decimalDigits: 0,
    rounding: 0,
    code: 'BIF',
  },
  BND: {
    symbol: 'BN$',
    symbolNative: '$',
    decimalDigits: 2,
    rounding: 0,
    code: 'BND',
  },
  BOB: {
    symbol: 'Bs',
    symbolNative: 'Bs',
    decimalDigits: 2,
    rounding: 0,
    code: 'BOB',
  },
  BRL: {
    symbol: 'R$',
    symbolNative: 'R$',
    decimalDigits: 2,
    rounding: 0,
    code: 'BRL',
  },
  BWP: {
    symbol: 'BWP',
    symbolNative: 'P',
    decimalDigits: 2,
    rounding: 0,
    code: 'BWP',
  },
  BYN: {
    symbol: 'Br',
    symbolNative: 'руб.',
    decimalDigits: 2,
    rounding: 0,
    code: 'BYN',
  },
  BZD: {
    symbol: 'BZ$',
    symbolNative: '$',
    decimalDigits: 2,
    rounding: 0,
    code: 'BZD',
  },
  CDF: {
    symbol: 'CDF',
    symbolNative: 'FrCD',
    decimalDigits: 2,
    rounding: 0,
    code: 'CDF',
  },
  CHF: {
    symbol: 'CHF',
    symbolNative: 'CHF',
    decimalDigits: 2,
    rounding: 0.05,
    code: 'CHF',
  },
  CLP: {
    symbol: 'CL$',
    symbolNative: '$',
    decimalDigits: 0,
    rounding: 0,
    code: 'CLP',
  },
  CNY: {
    symbol: 'CN¥',
    symbolNative: 'CN¥',
    decimalDigits: 2,
    rounding: 0,
    code: 'CNY',
  },
  COP: {
    symbol: 'CO$',
    symbolNative: '$',
    decimalDigits: 0,
    rounding: 0,
    code: 'COP',
  },
  CRC: {
    symbol: '₡',
    symbolNative: '₡',
    decimalDigits: 0,
    rounding: 0,
    code: 'CRC',
  },
  CVE: {
    symbol: 'CV$',
    symbolNative: 'CV$',
    decimalDigits: 2,
    rounding: 0,
    code: 'CVE',
  },
  CZK: {
    symbol: 'Kč',
    symbolNative: 'Kč',
    decimalDigits: 2,
    rounding: 0,
    code: 'CZK',
  },
  DJF: {
    symbol: 'Fdj',
    symbolNative: 'Fdj',
    decimalDigits: 0,
    rounding: 0,
    code: 'DJF',
  },
  DKK: {
    symbol: 'Dkr',
    symbolNative: 'kr',
    decimalDigits: 2,
    rounding: 0,
    code: 'DKK',
  },
  DOP: {
    symbol: 'RD$',
    symbolNative: 'RD$',
    decimalDigits: 2,
    rounding: 0,
    code: 'DOP',
  },
  DZD: {
    symbol: 'DA',
    symbolNative: 'د.ج.‏',
    decimalDigits: 2,
    rounding: 0,
    code: 'DZD',
  },
  EEK: {
    symbol: 'Ekr',
    symbolNative: 'kr',
    decimalDigits: 2,
    rounding: 0,
    code: 'EEK',
  },
  EGP: {
    symbol: 'EGP',
    symbolNative: 'ج.م.‏',
    decimalDigits: 2,
    rounding: 0,
    code: 'EGP',
  },
  ERN: {
    symbol: 'Nfk',
    symbolNative: 'Nfk',
    decimalDigits: 2,
    rounding: 0,
    code: 'ERN',
  },
  ETB: {
    symbol: 'Br',
    symbolNative: 'Br',
    decimalDigits: 2,
    rounding: 0,
    code: 'ETB',
  },
  GBP: {
    symbol: '£',
    symbolNative: '£',
    decimalDigits: 2,
    rounding: 0,
    code: 'GBP',
  },
  GEL: {
    symbol: 'GEL',
    symbolNative: 'GEL',
    decimalDigits: 2,
    rounding: 0,
    code: 'GEL',
  },
  GHS: {
    symbol: 'GH₵',
    symbolNative: 'GH₵',
    decimalDigits: 2,
    rounding: 0,
    code: 'GHS',
  },
  GNF: {
    symbol: 'FG',
    symbolNative: 'FG',
    decimalDigits: 0,
    rounding: 0,
    code: 'GNF',
  },
  GTQ: {
    symbol: 'GTQ',
    symbolNative: 'Q',
    decimalDigits: 2,
    rounding: 0,
    code: 'GTQ',
  },
  HKD: {
    symbol: 'HK$',
    symbolNative: '$',
    decimalDigits: 2,
    rounding: 0,
    code: 'HKD',
  },
  HNL: {
    symbol: 'HNL',
    symbolNative: 'L',
    decimalDigits: 2,
    rounding: 0,
    code: 'HNL',
  },
  HRK: {
    symbol: 'kn',
    symbolNative: 'kn',
    decimalDigits: 2,
    rounding: 0,
    code: 'HRK',
  },
  HUF: {
    symbol: 'Ft',
    symbolNative: 'Ft',
    decimalDigits: 0,
    rounding: 0,
    code: 'HUF',
  },
  IDR: {
    symbol: 'Rp',
    symbolNative: 'Rp',
    decimalDigits: 0,
    rounding: 0,
    code: 'IDR',
  },
  ILS: {
    symbol: '₪',
    symbolNative: '₪',
    decimalDigits: 2,
    rounding: 0,
    code: 'ILS',
  },
  INR: {
    symbol: '₹',
    symbolNative: '₹',
    decimalDigits: 2,
    rounding: 0,
    code: 'INR',
  },
  IQD: {
    symbol: 'IQD',
    symbolNative: 'د.ع.‏',
    decimalDigits: 0,
    rounding: 0,
    code: 'IQD',
  },
  IRR: {
    symbol: 'IRR',
    symbolNative: '﷼',
    decimalDigits: 0,
    rounding: 0,
    code: 'IRR',
  },
  ISK: {
    symbol: 'Ikr',
    symbolNative: 'kr',
    decimalDigits: 0,
    rounding: 0,
    code: 'ISK',
  },
  JMD: {
    symbol: 'J$',
    symbolNative: '$',
    decimalDigits: 2,
    rounding: 0,
    code: 'JMD',
  },
  JOD: {
    symbol: 'JD',
    symbolNative: 'د.أ.‏',
    decimalDigits: 3,
    rounding: 0,
    code: 'JOD',
  },
  JPY: {
    symbol: '¥',
    symbolNative: '￥',
    decimalDigits: 0,
    rounding: 0,
    code: 'JPY',
  },
  KES: {
    symbol: 'Ksh',
    symbolNative: 'Ksh',
    decimalDigits: 2,
    rounding: 0,
    code: 'KES',
  },
  KHR: {
    symbol: 'KHR',
    symbolNative: '៛',
    decimalDigits: 2,
    rounding: 0,
    code: 'KHR',
  },
  KMF: {
    symbol: 'CF',
    symbolNative: 'FC',
    decimalDigits: 0,
    rounding: 0,
    code: 'KMF',
  },
  KRW: {
    symbol: '₩',
    symbolNative: '₩',
    decimalDigits: 0,
    rounding: 0,
    code: 'KRW',
  },
  KWD: {
    symbol: 'KD',
    symbolNative: 'د.ك.‏',
    decimalDigits: 3,
    rounding: 0,
    code: 'KWD',
  },
  KZT: {
    symbol: 'KZT',
    symbolNative: 'тңг.',
    decimalDigits: 2,
    rounding: 0,
    code: 'KZT',
  },
  LBP: {
    symbol: 'LB£',
    symbolNative: 'ل.ل.‏',
    decimalDigits: 0,
    rounding: 0,
    code: 'LBP',
  },
  LKR: {
    symbol: 'SLRs',
    symbolNative: 'SL Re',
    decimalDigits: 2,
    rounding: 0,
    code: 'LKR',
  },
  LTL: {
    symbol: 'Lt',
    symbolNative: 'Lt',
    decimalDigits: 2,
    rounding: 0,
    code: 'LTL',
  },
  LVL: {
    symbol: 'Ls',
    symbolNative: 'Ls',
    decimalDigits: 2,
    rounding: 0,
    code: 'LVL',
  },
  LYD: {
    symbol: 'LD',
    symbolNative: 'د.ل.‏',
    decimalDigits: 3,
    rounding: 0,
    code: 'LYD',
  },
  MAD: {
    symbol: 'MAD',
    symbolNative: 'د.م.‏',
    decimalDigits: 2,
    rounding: 0,
    code: 'MAD',
  },
  MDL: {
    symbol: 'MDL',
    symbolNative: 'MDL',
    decimalDigits: 2,
    rounding: 0,
    code: 'MDL',
  },
  MGA: {
    symbol: 'MGA',
    symbolNative: 'MGA',
    decimalDigits: 0,
    rounding: 0,
    code: 'MGA',
  },
  MKD: {
    symbol: 'MKD',
    symbolNative: 'MKD',
    decimalDigits: 2,
    rounding: 0,
    code: 'MKD',
  },
  MMK: {
    symbol: 'MMK',
    symbolNative: 'K',
    decimalDigits: 0,
    rounding: 0,
    code: 'MMK',
  },
  MOP: {
    symbol: 'MOP$',
    symbolNative: 'MOP$',
    decimalDigits: 2,
    rounding: 0,
    code: 'MOP',
  },
  MUR: {
    symbol: 'MURs',
    symbolNative: 'MURs',
    decimalDigits: 0,
    rounding: 0,
    code: 'MUR',
  },
  MXN: {
    symbol: 'MX$',
    symbolNative: '$',
    decimalDigits: 2,
    rounding: 0,
    code: 'MXN',
  },
  MYR: {
    symbol: 'RM',
    symbolNative: 'RM',
    decimalDigits: 2,
    rounding: 0,
    code: 'MYR',
  },
  MZN: {
    symbol: 'MTn',
    symbolNative: 'MTn',
    decimalDigits: 2,
    rounding: 0,
    code: 'MZN',
  },
  NAD: {
    symbol: 'N$',
    symbolNative: 'N$',
    decimalDigits: 2,
    rounding: 0,
    code: 'NAD',
  },
  NGN: {
    symbol: '₦',
    symbolNative: '₦',
    decimalDigits: 2,
    rounding: 0,
    code: 'NGN',
  },
  NIO: {
    symbol: 'C$',
    symbolNative: 'C$',
    decimalDigits: 2,
    rounding: 0,
    code: 'NIO',
  },
  NOK: {
    symbol: 'Nkr',
    symbolNative: 'kr',
    decimalDigits: 2,
    rounding: 0,
    code: 'NOK',
  },
  NPR: {
    symbol: 'NPRs',
    symbolNative: 'नेरू',
    decimalDigits: 2,
    rounding: 0,
    code: 'NPR',
  },
  NZD: {
    symbol: 'NZ$',
    symbolNative: '$',
    decimalDigits: 2,
    rounding: 0,
    code: 'NZD',
  },
  OMR: {
    symbol: 'OMR',
    symbolNative: 'ر.ع.‏',
    decimalDigits: 3,
    rounding: 0,
    code: 'OMR',
  },
  PAB: {
    symbol: 'B/.',
    symbolNative: 'B/.',
    decimalDigits: 2,
    rounding: 0,
    code: 'PAB',
  },
  PEN: {
    symbol: 'S/.',
    symbolNative: 'S/.',
    decimalDigits: 2,
    rounding: 0,
    code: 'PEN',
  },
  PHP: {
    symbol: '₱',
    symbolNative: '₱',
    decimalDigits: 2,
    rounding: 0,
    code: 'PHP',
  },
  PKR: {
    symbol: 'PKRs',
    symbolNative: '₨',
    decimalDigits: 0,
    rounding: 0,
    code: 'PKR',
  },
  PLN: {
    symbol: 'zł',
    symbolNative: 'zł',
    decimalDigits: 2,
    rounding: 0,
    code: 'PLN',
  },
  PYG: {
    symbol: '₲',
    symbolNative: '₲',
    decimalDigits: 0,
    rounding: 0,
    code: 'PYG',
  },
  QAR: {
    symbol: 'QR',
    symbolNative: 'ر.ق.‏',
    decimalDigits: 2,
    rounding: 0,
    code: 'QAR',
  },
  RON: {
    symbol: 'RON',
    symbolNative: 'RON',
    decimalDigits: 2,
    rounding: 0,
    code: 'RON',
  },
  RSD: {
    symbol: 'din.',
    symbolNative: 'дин.',
    decimalDigits: 0,
    rounding: 0,
    code: 'RSD',
  },
  RUB: {
    symbol: 'RUB',
    symbolNative: '₽.',
    decimalDigits: 2,
    rounding: 0,
    code: 'RUB',
  },
  RWF: {
    symbol: 'RWF',
    symbolNative: 'FR',
    decimalDigits: 0,
    rounding: 0,
    code: 'RWF',
  },
  SAR: {
    symbol: 'SR',
    symbolNative: 'ر.س.‏',
    decimalDigits: 2,
    rounding: 0,
    code: 'SAR',
  },
  SDG: {
    symbol: 'SDG',
    symbolNative: 'SDG',
    decimalDigits: 2,
    rounding: 0,
    code: 'SDG',
  },
  SEK: {
    symbol: 'Skr',
    symbolNative: 'kr',
    decimalDigits: 2,
    rounding: 0,
    code: 'SEK',
  },
  SGD: {
    symbol: 'S$',
    symbolNative: '$',
    decimalDigits: 2,
    rounding: 0,
    code: 'SGD',
  },
  SOS: {
    symbol: 'Ssh',
    symbolNative: 'Ssh',
    decimalDigits: 0,
    rounding: 0,
    code: 'SOS',
  },
  SYP: {
    symbol: 'SY£',
    symbolNative: 'ل.س.‏',
    decimalDigits: 0,
    rounding: 0,
    code: 'SYP',
  },
  THB: {
    symbol: '฿',
    symbolNative: '฿',
    decimalDigits: 2,
    rounding: 0,
    code: 'THB',
  },
  TND: {
    symbol: 'DT',
    symbolNative: 'د.ت.‏',
    decimalDigits: 3,
    rounding: 0,
    code: 'TND',
  },
  TOP: {
    symbol: 'T$',
    symbolNative: 'T$',
    decimalDigits: 2,
    rounding: 0,
    code: 'TOP',
  },
  TRY: {
    symbol: 'TL',
    symbolNative: 'TL',
    decimalDigits: 2,
    rounding: 0,
    code: 'TRY',
  },
  TTD: {
    symbol: 'TT$',
    symbolNative: '$',
    decimalDigits: 2,
    rounding: 0,
    code: 'TTD',
  },
  TWD: {
    symbol: 'NT$',
    symbolNative: 'NT$',
    decimalDigits: 2,
    rounding: 0,
    code: 'TWD',
  },
  TZS: {
    symbol: 'TSh',
    symbolNative: 'TSh',
    decimalDigits: 0,
    rounding: 0,
    code: 'TZS',
  },
  UAH: {
    symbol: '₴',
    symbolNative: '₴',
    decimalDigits: 2,
    rounding: 0,
    code: 'UAH',
  },
  UGX: {
    symbol: 'USh',
    symbolNative: 'USh',
    decimalDigits: 0,
    rounding: 0,
    code: 'UGX',
  },
  UYU: {
    symbol: '$U',
    symbolNative: '$',
    decimalDigits: 2,
    rounding: 0,
    code: 'UYU',
  },
  UZS: {
    symbol: 'UZS',
    symbolNative: 'UZS',
    decimalDigits: 0,
    rounding: 0,
    code: 'UZS',
  },
  VEF: {
    symbol: 'Bs.F.',
    symbolNative: 'Bs.F.',
    decimalDigits: 2,
    rounding: 0,
    code: 'VEF',
  },
  VND: {
    symbol: '₫',
    symbolNative: '₫',
    decimalDigits: 0,
    rounding: 0,
    code: 'VND',
  },
  XAF: {
    symbol: 'FCFA',
    symbolNative: 'FCFA',
    decimalDigits: 0,
    rounding: 0,
    code: 'XAF',
  },
  XOF: {
    symbol: 'CFA',
    symbolNative: 'CFA',
    decimalDigits: 0,
    rounding: 0,
    code: 'XOF',
  },
  YER: {
    symbol: 'YR',
    symbolNative: 'ر.ي.‏',
    decimalDigits: 0,
    rounding: 0,
    code: 'YER',
  },
  ZAR: {
    symbol: 'R',
    symbolNative: 'R',
    decimalDigits: 2,
    rounding: 0,
    code: 'ZAR',
  },
  ZMK: {
    symbol: 'ZK',
    symbolNative: 'ZK',
    decimalDigits: 0,
    rounding: 0,
    code: 'ZMK',
  },
  ZWL: {
    symbol: 'ZWL$',
    symbolNative: 'ZWL$',
    decimalDigits: 0,
    rounding: 0,
    code: 'ZWL',
  },
};

export type CurrencyCode = keyof typeof CURRENCIES;

export const isCurrencyCode = (value: string): value is CurrencyCode => value in CURRENCIES;

export const parseCurrencyCode = (code: string): CurrencyCode =>
  isCurrencyCode(code) ? code : 'USD';

// Check with https://api.frankfurter.dev/v1/currencies
export const FRANKFURTER_CURRENCIES = [
  'AUD',
  'BGN',
  'BRL',
  'CAD',
  'CHF',
  'CNY',
  'CZK',
  'DKK',
  'EUR',
  'GBP',
  'HKD',
  'HUF',
  'IDR',
  'ILS',
  'INR',
  'ISK',
  'JPY',
  'KRW',
  'MXN',
  'MYR',
  'NOK',
  'NZD',
  'PHP',
  'PLN',
  'RON',
  'SEK',
  'SGD',
  'THB',
  'TRY',
  'USD',
  'ZAR',
];
